<template>
  <div class="radio" @click="change">
    <div class="box" :class="{ active: val }">
      <icon name="icongouxuan" size="12" />
    </div>
  </div>
</template>

<script>
export default {
  name: "Radio2",
  model: {
    prop: "value",
    event: "change",
  },
  data() {
    return { val: false };
  },
  watch: {
    value() {
      this.val = this.value;
    },
  },
  created() {
    this.val = this.value;
  },
  props: {
    value: {
      type: Boolean,
      default: () => false,
    },
  },
  methods: {
    change() {
      console.log(this.val);
      this.val = !this.val;
      this.$emit("change", !this._value);
    },
  },
};
</script>

<style lang="scss" scoped>
.radio {
  user-select: none;
  font-size: 0;
  font-weight: 400;
  color: #333333;
  display: inline-block;
  .box {
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 5px;
    box-sizing: border-box;
    border: 1px solid #979797;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    margin-right: 16px;
    &.active {
      background: #d52c1a;
      border-color: #d52c1a;
    }
  }
}
</style>
